#pragma warning(disable:4996)
#include<stdio.h>
#include<assert.h>
//模拟实现strstr（字符串查找函数）
char* My_Strstr(const char* target, const char* str)
{
	assert(target && str);
	if (!*str)
		return (char*)target;
	char* flag = (char*)target;
	char* p1, * p2;
	while (p1 = (char*)flag, p2 = (char*)str, *flag)
	{
		while (*p1 && *p2 && !(*p1 - *p2))	
			p1++, p2++;
		if (!*p2)
			return flag;
		flag++;
	}
	return NULL;
}
int main()
{
	char target[10]="aaabcd";
	char str[8] = "ab";
	char* ret = My_Strstr(target,str);
	printf("%s\n", ret);
	return 0;
}